import { PrismaClient } from '@prisma/client';
import { hash } from 'argon2';
import { Random } from 'mockjs';

const prisma = new PrismaClient();

async function run() {
  for (let i = 0; i < 10; i++) {
    await prisma.user.create({
      data: {
        name: Random.name(),
        email: Random.email(),
        password: await hash('123456'),
      },
    });
  }

  await prisma.user.update({
    where: { id: 1 },
    data: { name: 'liujing', password: await hash('123456') },
  });

  for (let i = 0; i < 10; i++) {
    await prisma.proj.create({
      data: {
        name: Random.ctitle(),
        shortName: Random.ctitle(),
        user: {
          connect: {
            name: 'liujing',
          },
        },
      },
    });

    for (let x = 0; x < 20; x++) {
      await prisma.zone.create({
        data: {
          name: Random.ctitle(),
          proj: {
            connect: {
              id: i + 1,
            },
          },
        },
      });
    }
  }
}

run();
